let vm = new Vue({
    el: 'form',
    data: {
        username: '',
        password: '',
        confirm: '',
        email: '',
        hasError: false
    },
    methods: {
        reg: function () {
            console.log('Submit');
            let form = new FormData();
            form.append("username", this.username);
            form.append("password", this.password);
            form.append("confirm", this.confirm);
            form.append("email", this.email);
            console.log(form);
            if (this.password != this.confirm) {
                this.message = "确认密码不一致";
                this.hasError = true;
                return;
            }

            axios.post("/register",form)
                .then(function (r) {
                    console.log(r.data);
                        if(r.data == "ok"){
                            vm.hasError = false;
                            //页面跳转
                            location.href = '/views/index';
                        }
                });
        }
    }
});